package com.pwser.shiro;

import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class PasswordHelper {
	
	private static String algorithmName = "MD5";
	private static int hashIterations = 1024;
	
	public static String encryptPassword(UsernamePasswordToken token) {
		String md5Password = new SimpleHash(algorithmName, token.getPassword(), ByteSource.Util.bytes(token.getUsername()), hashIterations).toHex();
		return md5Password;
	}

}
